package mysql

import "gorm.io/gorm"

type Goods struct {
	gorm.Model
	GoodsTitle string  `gorm:"type:varchar(30);not null;comment:商品标题"`
	GoodsPrice float64 `gorm:"type:decimal(10,2);not null;comment:商品价格"`
	GoodsStock int64   `gorm:"type:int(11);not null;comment:商品库存"`
	GoodsImg   string  `gorm:"type:varchar(255);not null;comment:商品图片"`
}

func (g *Goods) Create() error {
	return Db.Create(&g).Error
}

func (g *Goods) GetGoodsInfo(goodsId int) error {
	return Db.Where("id = ?", goodsId).Limit(1).Find(&g).Error
}
